]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
keyboard: Handle extended keyboards through TERMINAL input purpose
authorCarlos Garnacho <carlosg@gnome.org>
Fri, 26 Jan 2024 15:32:19 +0000 (16:32 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 29 Feb 2024 15:34:21 +0000 (16:34 +0100)
Drop the channeling of this specific signal from the InputMethod, and
update the OSK Keyboard object to using the purpose hint to find out
whether a extended keymap is necessary.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3162>

js/misc/inputMethod.js
js/ui/keyboard.js

index 53af39d8582230a1e33a4798ce7334b6b38c57d6..b393972ecb7839029ca0b7b0c4b5b0a505af966c 100644 (file)
@@ -21,7 +21,6 @@ const HAVE_REQUIRE_SURROUNDING_TEXT = GObject.signal_lookup('require-surrounding
 export const InputMethod = GObject.registerClass({
     Signals: {
         'surrounding-text-set': {},
-        'terminal-mode-changed': {},
     },
 }, class InputMethod extends Clutter.InputMethod {
     _init() {
@@ -34,7 +33,6 @@ export const InputMethod = GObject.registerClass({
         this._preeditAnchor = 0;
         this._preeditVisible = false;
         this._hidePanelId = 0;
-        this.terminalMode = false;
         this._ibus = IBus.Bus.new_async();
         this._ibus.connect('connected', this._onConnected.bind(this));
         this._ibus.connect('disconnected', this._clear.bind(this));
@@ -229,7 +227,6 @@ export const InputMethod = GObject.registerClass({
         this._surroundingTextCursor = null;
         this._surroundingTextAnchor = null;
         this._preeditStr = null;
-        this._setTerminalMode(false);
     }
 
     vfunc_set_cursor_location(rect) {
@@ -302,21 +299,11 @@ export const InputMethod = GObject.registerClass({
                  IBus.InputPurpose.TERMINAL)
             ibusPurpose = IBus.InputPurpose.TERMINAL;
 
-        this._setTerminalMode(
-            purpose === Clutter.InputContentPurpose.TERMINAL);
-
         this._purpose = ibusPurpose;
         if (this._context)
             this._context.set_content_type(this._purpose, this._hints);
     }
 
-    _setTerminalMode(terminalMode) {
-        if (this.terminalMode !== terminalMode) {
-            this.terminalMode = terminalMode;
-            this.emit('terminal-mode-changed');
-        }
-    }
-
     vfunc_filter_key_event(event) {
         if (!this._context)
             return false;
index 224e74f973423254754c2d9635dbc24bf1c26fb2..6896fad9cc31b9572caa12eb07c4c837db301fe0 100644 (file)
@@ -1413,10 +1413,6 @@ export const Keyboard = GObject.registerClass({
 
         this._updateKeys();
 
-        Main.inputMethod.connectObject(
-            'terminal-mode-changed', this._onTerminalModeChanged.bind(this),
-            this);
-
         this._keyboardController.connectObject(
             'active-group', this._onGroupChanged.bind(this),
             'groups-changed', this._onKeyboardGroupsChanged.bind(this),
@@ -1493,7 +1489,12 @@ export const Keyboard = GObject.registerClass({
     }
 
     _ensureKeys() {
-        const group = this._keyboardController.getCurrentGroup();
+        let group;
+        if (this._purpose === Clutter.InputContentPurpose.TERMINAL)
+            group = 'us-extended';
+        else
+            group = this._keyboardController.getCurrentGroup();
+
         if (!this._groups[group])
             this._groups[group] = this._createLayersForGroup(group);
     }
@@ -1617,7 +1618,7 @@ export const Keyboard = GObject.registerClass({
         if (enabled &&
             (!Main.inputMethod.currentFocus ||
              Main.inputMethod.hasPreedit() ||
-             Main.inputMethod.terminalMode)) {
+             this._purpose === Clutter.InputContentPurpose.TERMINAL)) {
             this._keyboardController.keyvalPress(Clutter.KEY_BackSpace);
             this._backspacePressed = true;
             return;
@@ -1803,10 +1804,6 @@ export const Keyboard = GObject.registerClass({
         this._updateKeys();
     }
 
-    _onTerminalModeChanged() {
-        this._updateKeys();
-    }
-
     _onKeyboardGroupsChanged() {
         let nonGroupActors = [this._emojiSelection, this._keypad];
         this._aspectContainer.get_children().filter(c => !nonGroupActors.includes(c)).forEach(c => {
@@ -2220,9 +2217,6 @@ class KeyboardController extends Signals.EventEmitter {
     }
 
     getCurrentGroup() {
-        if (Main.inputMethod.terminalMode)
-            return 'us-extended';
-
         // Special case for Korean, if Hangul mode is disabled, use the 'us' keymap
         if (this._currentSource.id === 'hangul') {
             const inputSourceManager = InputSourceManager.getInputSourceManager();